def check(n):
    p = 2
    while n % p != 0:
        p += 1
    return p == n


numbers = input().split()
nnn = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
nnn_r = {'zero': '0',
         'one': '1',
         'two': '2',
         'three': '3',
         'four': '4',
         'five': '5',
         'six': '6',
         'seven': '7',
         'eight': '8',
         'nine': '9'}
flag = True
for k in numbers:
    if k not in nnn:
        print('Wrong input')
        flag = False
        break
if flag is True:
    a = ''
    for i in numbers:
        a += nnn_r.get(i)
    a = int(a)
    if len(str(a)) != 3:
        print('Wrong input')
    elif str(a)[0] == '0':
        print('Wrong input')
    else:
        c = a
        c1 = a
        while check(c) is False:
            c += 1
        while check(c1) is False:
            c1 -= 1
        if (a - c1) <= (c - a):
            print(c1)
        else:
            print(c)





